package com.seh.contentcenter.controller;

import com.seh.contentcenter.dto.ChatDTO;
import com.seh.contentcenter.entity.Chat;
import com.seh.contentcenter.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/chat")
public class ChatController {
    @Autowired
    private ChatService chatService;

    /**
     * 新增消息记录
     *
     * @param chatDTO
     */
    @PostMapping("/save")
    public void saveChat(@RequestBody ChatDTO chatDTO) {
        chatService.saveChat(chatDTO);
    }

    /**
     * 查询消息记录
     *
     * @param fromId
     * @param toId
     * @return
     */
    @GetMapping("/getChatRecord")
    public List<Chat> getChatRecord(@RequestParam Integer fromId, @RequestParam Integer toId) {
        return chatService.getChatRecord(fromId, toId);
    }


}
